home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / xinetd / xlog.1.0.9 / impl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-07  |  2.4 KB  |  98 lines

  1. /*
  2.  * (c) Copyright 1992 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7.  
  8. /*
  9.  * $Id: impl.h,v 1.2 1992/10/15 00:21:38 panos Exp $
  10.  */
  11.  
  12.  
  13. #define DEFINE_LINK_TYPE( type, name )        struct { type *next, *prev ; } name
  14.  
  15.  
  16. #define NEXT( obj, field )                        (obj)->field.next
  17. #define PREV( obj, field )                        (obj)->field.prev
  18.  
  19. #define INIT_LINKS( obj, field )                                                            \
  20.                     {                                                                                \
  21.                         NEXT( obj, field ) = obj ;                                            \
  22.                         PREV( obj, field ) = obj ;                                            \
  23.                     }
  24.  
  25. /*
  26.  * Link new object after object using the specified field
  27.  */
  28. #define LINK( obj, new_obj, field )                                                        \
  29.             {                                                                                        \
  30.                 NEXT( new_obj, field ) = NEXT( obj, field ) ;                        \
  31.                 PREV( new_obj, field ) = obj ;                                            \
  32.                 NEXT( obj, field ) = new_obj ;                                            \
  33.                 PREV( NEXT( obj, field ), field ) = new_obj ;                        \
  34.             }
  35.  
  36. #define UNLINK( obj, field )                                                                \
  37.                     {                                                                                \
  38.                         NEXT( PREV( obj, field ), field ) = NEXT( obj, field ) ;    \
  39.                         PREV( NEXT( obj, field ), field ) = PREV( obj, field ) ;    \
  40.                     }
  41.  
  42.  
  43. /*
  44.  * xlog linking:
  45.  *     When xlog1 is linked to xlog2 (i.e. errors on xlog1 are reported to 
  46.  *        xlog2) we use the clients field on xlog2 and the other_users field 
  47.  *        on xlog1
  48.  */
  49. struct xlog
  50. {
  51.     xlog_e type ;
  52.     int active ;
  53.     char *id ;
  54.     int flags ;
  55.     void (*callback)() ;
  56.     void *callback_arg ;
  57.     struct xlog *use ;                        /* xlog we report errors to         */
  58.     struct xlog *clients ;                    /* linked list of xlogs that use */
  59.                                                     /* this xlog to report errors     */
  60.     DEFINE_LINK_TYPE( struct xlog, other_users ) ;
  61.     struct xlog_ops
  62.     {
  63.         int (*init) __ARGS( ( struct xlog *, va_list ) ) ;
  64.         void (*fini) __ARGS( ( struct xlog * ) ) ;
  65.         int (*write) __ARGS( ( struct xlog *, char *, int, int, va_list ) ) ;
  66.         int (*control) __ARGS( ( struct xlog *, xlog_cmd_e, va_list ) ) ;
  67.         int (*parms) __ARGS( ( va_list ) ) ;
  68.     } *ops ;
  69.     void *data ;
  70. } ;
  71.  
  72. typedef struct xlog xlog_s ;
  73.  
  74. typedef void (*voidfunc)() ;
  75.  
  76. #define XP( p )                        ((struct xlog *)(p))
  77.  
  78. #define XLOG_NULL                        XP( NULL )
  79.  
  80. #ifndef FALSE
  81. #define FALSE        0
  82. #define TRUE        1
  83. #endif
  84.  
  85. #ifndef NULL
  86. #define NULL        0
  87. #endif
  88.  
  89. #define NEW( type )                    (type *) malloc( sizeof( type ) )
  90. #define FREE( p )                        (void) free( (char *)p )
  91.  
  92. #define PRIVATE        static
  93.  
  94. char *__xlog_add_errno() ;
  95. char *__xlog_explain_errno() ;
  96. char *__xlog_new_string() ;
  97.  
  98.